export function checkDate (newVal, oldVal, data) {
  console.log(typeof (newVal), oldVal, data)
  if (newVal.length === 1) {
    if (newVal.length > oldVal.length) {
      if (newVal.charAt(0) !== '1' && newVal.charAt(0) !== '0') {
        data = '0' + newVal + '/'
      }
    }
  } else if (newVal.length === 2) {
    if (parseInt(newVal.charAt(1)) > 2) {
      data = newVal.substring(0, 1)
      return
    }
    if (newVal.length > oldVal.length) {
      data = newVal + '/'
    }
  } else if (newVal.length === 3) {
    if (newVal.length > oldVal.length) {
      if (parseInt(newVal.charAt(2)) > 3) {
        data = newVal.substring(0, 2)
        return
      }
      if (newVal.charAt(2) !== '/') {
        data = newVal.substring(0, 2) + '/' + newVal.charAt(2)
      }
    }
  } else if (newVal.length === 4) {
    if (newVal.length > oldVal.length) {
      if (parseInt(newVal.charAt(3)) > 3) {
        data = newVal.substring(0, 2)
      }
    }
  } else if (newVal.length === 5) {
    if (newVal.length > oldVal.length) {
      if (newVal.charAt(3) === '3') {
        if (newVal.substring(0, 2) === '01' || newVal.substring(0, 2) === '03' || newVal.substring(0, 2) === '05' || newVal.substring(0, 2) === '07' || newVal.substring(0, 2) === '08' || newVal.substring(0, 2) === '10' || newVal.substring(0, 2) === '12') {
          if (parseInt(newVal.charAt(4)) > 1) {
            data = newVal.substring(0, 4)
            return
          }
        } else if (newVal.substring(0, 2) === '04' || newVal.substring(0, 2) === '06' || newVal.substring(0, 2) === '09' || newVal.substring(0, 2) === '11') {
          if (parseInt(newVal.charAt(4)) > 0) {
            data = newVal.substring(0, 4)
            return
          }
        }
      }
      data = newVal + '/'
    }
  } else if (newVal.length === 6) {
    if (newVal.length > oldVal.length) {
      if (newVal.charAt(5) !== '/') {
        data = newVal.substring(0, 5) + '/' + newVal.charAt(5)
      }
    }
  }
}
